import {createRouter, createWebHistory} from 'vue-router'
import HomeView from '../views/Home.vue'
import menus from './menu'

const router = createRouter({
    history: createWebHistory(import.meta.env.BASE_URL),
    routes: [
        // 基础路由
        {
            path:"/",
            redirect:"/login"
        },
         {
            path: '/login',
            name: 'login',
            component: () => import('../views/Login.vue')
        },
        {
            path: '/register',
            name: 'register',
            component: () => import('../views/Register.vue')
        },
        {
            path: '/home',
            name: 'home',
            component: HomeView,
            children:menus
          /*   children: [

                {
                    path: "/dashboard",
                    name: "Dashboard",
                    meta: {title: "首页", icon: "HomeFilled", top: true},
                    component: () => import('@/views/Dashboard/Dashboard.vue')
                },

                {
                    path: "/memberCenter",
                    name: "MemberCenter",
                    meta: {
                        title: "会员管理",
                        icon: "User",
                        top: true
                    },
                    children: [
                        {
                            path: "member",
                            name: "Member",
                            meta: {
                                title: "会员",
                                icon: "UserFilled"
                            },
                            component: () => import('@/views/MemberCenter/Member.vue')
                        },
                        {
                            path: "memberCard",
                            name: "MemberCard",
                            meta: {
                                title: "会员卡",
                                icon: "Postcard"
                            },
                            component: () => import('@/views/MemberCenter/MemberCard.vue')
                        },
                        {
                            path: "memberBind",
                            name: "MemberBind",
                            meta: {
                                title: "会员绑定",
                                icon: "Postcard"
                            },
                            component: () => import('@/views/MemberCenter/MemberBind.vue')
                        }
                    ]
                },
                {
                    path: "/course",
                    name: "Course",
                    meta: {
                        title: "团课管理",
                        icon: "Grid",
                        top: true
                    },
                    children: [
                        {
                            path: "courseList",
                            name: "CourseList",
                            meta: {
                                title: "团课课程",
                                icon: "List"
                            },
                            component: () => import('@/views/Course/CourseList.vue')
                        },
                        {
                            path: "courseSchedule",
                            name: "CourseSchedule",
                            meta: {
                                title: "团课课表",
                                icon: "Calendar"
                            },
                            component: () => import('@/views/Course/CourseSchedule.vue')
                        },
                        {
                            path: "courseReservation",
                            name: "CourseReservation",
                            meta: {
                                title: "团课预约设置",
                                icon: "Setting"
                            },
                            component: () => import('@/views/Course/CourseReservation.vue')
                        }
                    ]
                },
                {
                    path: "/teacher",
                    name: "Teacher",
                    meta: {
                        title: "老师管理",
                        icon: "Avatar",
                        top: true
                    },
                    component: () => import('@/views/Teacher/Teacher.vue')
                },
                {
                    path: "/statistics",
                    name: "statistics",
                    meta: {
                        title: "数据统计",
                        icon: "TrendCharts",
                        top: true
                    },
                    children: [
                        {
                            path: "cardListStat",
                            name: "CardListStat",
                            meta: {
                                title: "会员卡统计",
                                icon: "PieChart"
                            },
                            component: () => import('@/views/statistics/CardListStat.vue')
                        },
                        {
                            path: "cardCostStat",
                            name: "CardCostStat",
                            meta: {
                                title: "收费统计",
                                icon: "Histogram"
                            },
                            component: () => import('@/views/statistics/CardCostStat.vue')
                        },
                        {
                            path: "classCostStat",
                            name: "ClassCostStat",
                            meta: {
                                title: "消课统计",
                                icon: "Histogram"
                            },
                            component: () => import('@/views/statistics/ClassCostStat.vue')
                        },
                        {
                            path: "classHourStat",
                            name: "ClassHourStat",
                            meta: {
                                title: "总课次统计",
                                icon: "Histogram"
                            },
                            component: () => import('@/views/statistics/ClassHourStat.vue')
                        },
                        {
                            path: "memberNumStat",
                            name: "MemberNumStat",
                            meta: {
                                title: "新增与流失统计",
                                icon: "Histogram"
                            },
                            component: () => import('@/views/statistics/MemberNumStat.vue')
                        }
                    ]
                },
                {
                    path: "/profile",
                    name: "profile",
                    meta: {
                        "title": "个人中心",
                        "icon": null,
                        "top": false
                    },
                    children: [
                        {
                            path: "modifyPwd",
                            name: "ModifyPwd",
                            meta: {
                                title: "修改密码",
                                icon: "PieChart"
                            },
                            component: () => import('@/views/profile/ModifyPwd.vue')
                        },
                        {
                            path: "info",
                            name: "Info",
                            meta: {
                                title: "个人信息",
                                icon: "Histogram"
                            },
                            component: () => import('@/views/profile/Info.vue')
                        }
                    ]
                }


            ] */
            
        },

       
    ]
})
router.beforeEach((to, from, next) => {
    console.log('路由前置导航守卫==', to, from)
    next()

})

export default router
